# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator


from jms.dim.dim_lmdm_sys_network import jms_dim__dim_lmdm_sys_network
from jms.dwd.dwd_warhouse.dwd_wide_unsign_summary_waybill_dt import jms_dwd__dwd_wide_unsign_summary_waybill_dt
from jms.dwd.dwd_warhouse.dwd_wide_sign_summary_waybill_dt import jms_dwd__dwd_wide_sign_summary_waybill_dt
from jms.dim.dim_lmdm_sys_staff import jms_dim__dim_lmdm_sys_staff

jms_ai_group__network_every_day_information = SparkSqlOperator(
    task_id='jms_ai_group__network_every_day_information',
    email=['payne.jiang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_ai_group__network_every_day_information_{{ execution_date | date_add(1) | cst_ds }}',
    email_on_retry=True,
    retries=1,
    sql='jms/aigroup/ai_group/network_every_day_information/execute.sql',
    yarn_queue='pro',
    driver_memory='3G' , 
    driver_cores=2 , 
    executor_memory='4G' , 
    executor_cores=2 , 
    pool_slots=2,
    pool='unlimited_pool',
    num_executors=16 , 
    conf={
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
        'spark.dynamicAllocation.maxExecutors'             : 19 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.sql.shuffle.partitions': 400,
          'spark.port.maxRetries': 100
          },
    execution_timeout=timedelta(hours=2),
    priority_weight=20,
)

jms_ai_group__network_every_day_information << [
    jms_dwd__dwd_wide_unsign_summary_waybill_dt,
    jms_dwd__dwd_wide_sign_summary_waybill_dt,
    jms_dim__dim_lmdm_sys_network,
    jms_dim__dim_lmdm_sys_staff
]
